import { getLanguage, queryMyInfo } from '@/public/Api/user.js'
import { clearValue } from '@/public/storeage/index.js'
export default  {
	data() {
		return {
			outTimer: null
		}
	},
	methods: {
		
		// 获取语言
		async getlangs () {
				try{
					const { data: res } = await getLanguage()
					if(res.code != 200) throw res.data
					const langs = res.data === '中文' ? 'zh-CN' : 'en'
					this.$store.commit('changeLang', langs)
					this.$i18n.locale = langs
				}catch(e){ console.log(e); }
		},
		
		// 获取用户信息
		async getUserInfo () {
			try{
				const { data: res } = await queryMyInfo()
				if(res.code != 200) throw res.data
				this.$store.commit('changeuserInfo', res.data)
			}catch(e){ console.log(e); }
		},
		signout () {
			clearValue()
			uni.showLoading({
				title: '正在退出...',
				mask: false
			});
			this.outTimer = setTimeout(() =>{
				uni.hideLoading()
				uni.navigateTo({
					url: '/pages/login/login',
				})
			clearTimeout(this.outTimer)
			}, 500)

		}
	}
}